package c.c.k.vo;

import c.c.k.emums.EnumSuggestionType;
import c.c.k.pojo.Stock;
import cn.hutool.core.util.RandomUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
 * Created by chenck on 2022/3/19.
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class StockVO extends Stock {
    private Integer index;
    private Double percent;//占比
    private Boolean hasFollow;//是否已关注

    public EnumSuggestionType getSuggestionType(){
        //return EnumSuggestionType.getType(RandomUtil.randomInt(1, 8));
        double diefu = this.getNowPrice()/this.getMaxPrice();
        if(diefu<0.2)
            return EnumSuggestionType.P100;
        else if(diefu<0.3)
            return EnumSuggestionType.P50;
        else if(diefu<0.4)
            return EnumSuggestionType.P20;
        else
            return EnumSuggestionType.P00;
    }
}
